package com.mach.platform.sprider.dev;

import java.util.HashMap;

public class TcpService {

    private static TcpService me = new TcpService();

    public static TcpService get(){return me;}

    private HashMap<String, TcpWorker> worksMap = new HashMap<String, TcpWorker>();

    private TcpService(){
        intiTcpWorksMap();
    }

    private void intiTcpWorksMap(){
        //worksMap.put("", new TcpWorker("",80));
    }

    public TcpWorker regWorkTcpWork(String ip, Integer port){
        TcpWorker wk = worksMap.get(ip + ":" + port);

        if(wk == null){
            wk = new TcpWorker(ip,port);
            worksMap.put(ip+":"+port, wk);
        }

        return wk;
    }

    public TcpWorker getWork(String ip, Integer port){
        TcpWorker wk = worksMap.get(ip + ":" + port);
        return wk;
    }

}
